<?php
namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis as Redis;
class CheckController extends Controller
{
    static public function CheckParameter($parameters,$CheckParameters)
    {
        foreach($CheckParameters as $k=>$v)
        {
            if(!array_key_exists($v,$parameters))
            {
                return false;
            }
        }
        return true;
    }
    static public function Nonempty($parameters)
    {
        if(!empty($parameters))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    static public function NonemptyArray($parameters)
    {
        foreach($parameters as $key=>$parameter)
        {
            if(empty($parameter))
            {
                return false;
            }
        }
        return true;
    }
    static public function CheckUser($request)
    {
        $UserLogin=$request->header('UserLogin')?$request->header('UserLogin'):'';
        $UserToken=$request->header('UserToken')?$request->header('UserToken'):'';
        $GroupId=$request->header('GroupId')?$request->header('GroupId'):'';
        $redis = app('redis.connection');
        $Token=$redis->GET($UserLogin.'G'.$GroupId.'_token');
        if($UserToken==$Token)
        {
                return true;
        }
        else
        {
            return false;
        }
    }
}